<?php echo $this->render('./_common/header.phtml');?>
<script type="text/javascript" src="<?php echo $this->baseUrl();?>/public/default/js/nicEdit-latest.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>  
<script type="text/javascript">
/* Code based on Google Map APIv3 Tutorials */
var gmapdata;
var gmapmarker;
var infoWindow;

var def_zoomval = 15;
var def_longval = <?php echo $this->longval;?>;
var def_latval = <?php echo $this->latval;?>;

function if_gmap_init()
{
	// init for Editor
	new nicEditor({buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image']}).panelInstance('placeDescription');
	
	// init for Map
	document.getElementById("addressInput").value = '<?php echo $this->locname;?>';
	var curpoint = new google.maps.LatLng(def_latval,def_longval);

	gmapdata = new google.maps.Map(document.getElementById("mapitems"), {
		center: curpoint,
		zoom: def_zoomval,
		mapTypeId: 'roadmap'
		});

	gmapmarker = new google.maps.Marker({
					map: gmapdata,
					position: curpoint
				});

	infoWindow = new google.maps.InfoWindow;
	google.maps.event.addListener(gmapdata, 'click', function(event) {
		document.getElementById("longval").value = event.latLng.lng().toFixed(6);
		document.getElementById("latval").value = event.latLng.lat().toFixed(6);
		gmapmarker.setPosition(event.latLng);
	});

	google.maps.event.addListener(gmapmarker, 'click', function() {
		infoWindow.open(gmapdata, gmapmarker);
	});

	document.getElementById("longval").value = def_longval;
	document.getElementById("latval").value = def_latval;

	return false;
} // end of if_gmap_init


function if_gmap_loadpicker()
{
	var longval = document.getElementById("longval").value;
	var latval = document.getElementById("latval").value;

	if (longval.length > 0) {
		if (isNaN(parseFloat(longval)) == true) {
			longval = def_longval;
		} // end of if
	} else {
		longval = def_longval;
	} // end of if

	if (latval.length > 0) {
		if (isNaN(parseFloat(latval)) == true) {
			latval = def_latval;
		} // end of if
	} else {
		latval = def_latval;
	} // end of if

	var curpoint = new google.maps.LatLng(latval,longval);

	gmapmarker.setPosition(curpoint);
	gmapdata.setCenter(curpoint);
	return false;
} // end of if_gmap_loadpicker

</script>
<div class="container bigtoppadding midtoppadding">
	<section class="row midbottompadding bigtoppadding">
		<h5 class="black whitetext bold leftpadding rightpadding">Chỉnh sửa địa
			điểm đã thêm vào VnSpot.Net</h5>
	</section>
</div>
<div class="container white bigpadding">
	<section class="row">
		<div class="eight columns blackvertical">	
		<div id="mapitems" style="width: 600px; height: 350px"></div>
<!-- 			<div class="map-frame" id="map"><span class="loading"></span></div> -->
		</div>
		<div class="four columns">
			<div class="row">
			<form method="post" action="" id="addPlaceFrm"
					enctype="multipart/form-data">
			<p>
			<input type="hidden" value="<?php echo $this->id;?>" id="placeId" name="placeId">
			<input type="hidden" value="" id="longval" name="longval">
			<input type="hidden" value="" id="latval" name="latval">
			</p>
				<dl class="field twelve columns">
					<dd> <label> Tên địa điểm của bạn : </label></dd>
					<dt class="text">
						<input type="text" name="locname" id="addressInput" value="<?php echo $this->locname;?>" placeholder="Vui lòng nhập lại tên địa điểm"/>
					</dt>
				</dl>
				<dl class="field twelve columns">
							<dd>
								<label>Ảnh : </label>
							</dd>
							<dt>
								<img class="five columns push_one" src="<?php echo $this->baseUrl().'/'.$this->photo;?>" alt="<?php echo $this->locname;?>" title="<?php echo $this->locname;?>" />
							
							<?php echo $this->formFile('picture');?>
							</dt>
				</dl>
				<dl class="field twelve columns">
							<dd>
								<label>Mô tả địa điểm : </label>
							</dd>
							<dt>							
							<textarea style="width: 100%" name="description" id="placeDescription" placeholder="Nhập vào mô tả cho địa điểm này" title="Nhập vào mô tả cho địa điểm này" ><?php echo $this->description;?></textarea>
							</dt>
						</dl>
						<input class="submit twelve columns" type="submit"
							value="Sửa địa điểm này" id="submit" name="btnEdit"/>
						<input class="submit twelve columns" type="submit"
							value="Xóa địa điểm này ?" id="submit" name="btnDelete" onclick="return confirm('Bạn có chắc muốn xóa địa điểm này?');"/>
				</form>
			</div>
		</div>		
	</section>
<section class="row midpadding">
<h5 class="blacktext extrabold midbottommargin">Danh sách địa điểm đã thêm vào VnSpot.Net</h5>
<?php 
for($i=0; $i<count($this->arrListPlace); $i++) {
if((($i+1)%4) == 1) {
?>
<div class="three columns alpha">
	<ul class="meta leftpadding">
		<li class="blacktext icon-hand-right"> &nbsp; <a href="<?php echo $this->baseUrl()."/place/edit/id/".$this->arrListPlace[$i]['Id'];?>"><?php echo $this->arrListPlace[$i]['Name'];?></a></li>
	</ul>
</div>
<?php
} else {
?>
<div class="three columns">
	<ul class="meta leftpadding">
		<li class="blacktext icon-hand-right">&nbsp; <a href="<?php echo $this->baseUrl()."/place/edit/id/".$this->arrListPlace[$i]['Id'];?>"><?php echo $this->arrListPlace[$i]['Name'];?></a></li>
	</ul>
</div>
<?php 
}
}?>
</section>

</div>
<!-- end of #container -->

<?php echo $this->render('./_common/footer.phtml');?>